package com.zykj.command.fab;

import com.zykj.command.Command;

/**
 * @author zhoulj(周利军) [1217102780@qq.com]
 * @Module ID:   <(模块)类编号，可以引用系统设计中的类编号>
 * @Comments: <对此类的描述，可以引用系统设计中的描述>
 * @JDK version used:      <JDK1.8> 56
 * @since 2019/1/2-10:56
 */
public class DianshanLowCommand implements Command {
    Diaoshan diaoshan;
    int speed ;
    public DianshanLowCommand(Diaoshan diaoshan) {
        this.diaoshan = diaoshan;
    }

    @Override
    public void execute() {
        speed = diaoshan.getSpeed();
        diaoshan.low();
    }

    /**
     * @return void
     * @Comments: <Version1.2 加入撤销命令>
     * @author zhoulj(周利军) [1217102780@qq.com]
     * @since 2019/1/2-10:34
     */
    @Override
    public void undo() {
        if(speed == Diaoshan.HIGH) {
            diaoshan.high();
        }else if(speed == Diaoshan.MEDIUM) {
            diaoshan.medium();
        }else if(speed == Diaoshan.LOW) {
            diaoshan.low();
        }else {
            diaoshan.off();
        }
    }
}
